/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.ArrayList;
import java.util.List;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;

/**
 * <p>Project: jse2204 - Lam3
 * <p>Powered by webrx On 2022-09-28 11:24:05
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Lam3 {
    public static void main(String[] args) {
        //UnaryOperator<Integer> u = i -> i * i;
        //System.out.println(u.apply(3));

        List<Integer> list = new ArrayList<>(List.of(1,2,3,4,5));

        //list.stream().filter(e->e%2==0).forEach(e->System.out.printf("%03d%n",e));
        list.stream().filter(e->e%2==0).forEach(System.out::print);
        list.stream().filter(e->e%2==0).forEach(System.out::println);

        System.out.println(list);

        for(int i=0;i<list.size();i++){
            list.set(i,list.get(i)*list.get(i));
        }
        System.out.println(list);

        //
        List<Integer> list2 = list.stream().map(i->i*i).collect(Collectors.toList());
        System.out.println(list2);
    }
}
